package com.msb.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.msb.feign.OrderServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/order")
@RefreshScope
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${info:empty}")
    private String  info;
    @Autowired
    private OrderServiceFeign orderServiceFeign;

    @GetMapping("/save")
    public String save() {
        String save = orderServiceFeign.save();
        return save;
    }

    @GetMapping("/list")
    @SentinelResource(value = "info")
    public String list() {
        return info;
    }

    @GetMapping("info")
    public String getInfo() {
        System.out.println(info);
        return "访问成功";
    }
}
